<template>
	<view style="padding: 30px;">
		<button @click="onSetTimeCall()">单词定时器setTimeout</button>
		<button @click="onSetTimeCallxy()">带参数</button>
		<button @click="onTimeoutClear()" type="warn">取消单次定时器</button>
		<button @click="onInteral()" >周期打印</button>
		<button @click="onClearInter()" type="warn">取消单次定时器</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			onSetTimeCall(){
				console.log("onSetTimeCall-->")
				// setTimeout(callback,ms,ayn[])
				setTimeout(()=>{
					console.log("我延迟三秒才会打印");
				},3000)
			},
			onSetTimeCallxy(name,pwd){
				console.log("onSetTimeCallxy-->name:"+name+",pwd:"+pwd);
				setTimeout((x,y)=>{
					console.log("我可以传参数了>x:"+x+",y:"+y);	
				},2000,name,pwd)
			},
			onTimeoutClear(){
				console.log("onTimeoutClear----->定时器被我取消了:"+this.setTimeout)
				clearTimeout(this.timeoutID);
			},
			onInteral(){
				setInterval(()=>{
					this.count++;
					console.log("周期打印 count:",this.count);
			},1000)
			},
			onClearInter(){
				console.log("onClearInter:",this)
				
			}
		}
	}
</script>

<style>
button{
	margin: 10px;
}
</style>
